home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #1 / Amiga Plus CD - 2000 - No. 1.iso / Tools / Dev / mamesrc / src / amiga / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-03  |  18.1 KB  |  589 lines

  1. /**************************************************************************
  2.  *
  3.  * Copyright (C) 1999 Mats Eirik Hansen (mats.hansen@triumph.no)
  4.  *
  5.  * $Id: config.c,v 1.1 1999/04/28 18:51:46 meh Exp meh $
  6.  *
  7.  * $Log: config.c,v $
  8.  * Revision 1.1  1999/04/28 18:51:46  meh
  9.  * Initial revision
  10.  *
  11.  *
  12.  *************************************************************************/
  13.  
  14. #include <stdio.h>
  15. #include <strings.h>
  16.  
  17. #include <inline/dos.h>
  18.  
  19. #include <moo/db.h>
  20.  
  21. #include "main.h"
  22. #include "version.h"
  23.  
  24. LONG Config[CFG_ITEMS];
  25.  
  26. static char       **SectionNames;
  27. static int        NumConfigs;
  28. static dbfile_t   *DBFile;
  29. static dbarg_t    *DBArg;
  30. #ifdef MESS
  31. static dbstring_t *DBImage;
  32. #else
  33. static dbbool_t   *DBShow;
  34. static dbbool_t   *DBUseDefaults;
  35. #endif
  36. static dbbool_t   *DBFound;
  37. static dbbool_t   *DBAntialiasing;
  38. static dbbool_t   *DBTranslucency;
  39. static dbint_t    *DBBeamWidth;
  40. static dbint_t    *DBVectorFlicker;
  41. static dbenum_t   *DBScreenType;
  42. static dbuint_t   *DBScreenMode;
  43. static dbenum_t   *DBDirectMode;
  44. static dbbool_t   *DBDirtyLines;
  45. static dbint_t    *DBDepth;
  46. static dbbool_t   *DBAllow16Bit;
  47. static dbbool_t   *DBFlipX;
  48. static dbbool_t   *DBFlipY;
  49. static dbbool_t   *DBAutoFrameSkip;
  50. static dbint_t    *DBFrameSkip;
  51. static dbint_t    *DBWidth;
  52. static dbint_t    *DBHeight;
  53. static dbenum_t   *DBBuffering;
  54. static dbenum_t   *DBRotation;
  55. static dbenum_t   *DBSound;
  56. static dbint_t    *DBAudioChannel0;
  57. static dbint_t    *DBAudioChannel1;
  58. static dbint_t    *DBAudioChannel2;
  59. static dbint_t    *DBAudioChannel3;
  60. static dbint_t    *DBMinFreeChip;
  61. static dbenum_t   *DBJoy1Type;
  62. static dbint_t    *DBJoy1ButtonBTime;
  63. static dbint_t    *DBJoy1AutoFireRate;
  64. static dbenum_t   *DBJoy2Type;
  65. static dbint_t    *DBJoy2ButtonBTime;
  66. static dbint_t    *DBJoy2AutoFireRate;
  67. static dbstring_t *DBRomPath;
  68. static dbstring_t *DBSamplePath;
  69. #ifdef POWERUP
  70. static dbbool_t   *DBAsyncPPC;
  71. #endif
  72.  
  73. void MakeDirs(void);
  74.  
  75. int AllocConfig(int argc, char **argv)
  76. {
  77. #ifndef MESS
  78.   static dbenumdef_t dbshow_defs[] = {{"All",0},{"Found",1},{NULL,0}};
  79. #endif
  80.   static dbenumdef_t dbscreentype_defs[] = {{"Best",0},{"WB",1},{"Custom",2},{"UserSelect",3},{NULL,0}};
  81.   static dbenumdef_t dbdirectmode_defs[] = {{"Off",0},{"Draw",1},{"Copy",2},{NULL,0}};
  82.   static dbenumdef_t dbbuffering_defs[]  = {{"Single",0},{"Double",1},{"Triple",2},{NULL,0}};
  83.   static dbenumdef_t dbrotation_defs[]   = {{"No",0},{"Left",1},{"Right",2},{NULL,0}};
  84.   static dbenumdef_t dbsound_defs[]      = {{"No",0},{"Paula",1},{"AHI",2},{NULL,0}};
  85.   static dbenumdef_t dbjoy1type_defs[]   = {{"No",0},{"JoyStickPort2",1},{"JoyPadPort2",2},{"MousePort1",3},{NULL,0}};
  86.   static dbenumdef_t dbjoy2type_defs[]   = {{"No",0},{"JoyStickPort1",1},{"JoyPadPort1",2},{NULL,0}};
  87.   int i;
  88.  
  89.   DBFile        = NULL;
  90.   SectionNames    = NULL;
  91.   Config[CFG_DRIVER]  = -2;
  92.  
  93.   for(NumConfigs = 0; Drivers[NumConfigs]; NumConfigs++);
  94.  
  95. #ifdef MESS
  96.   NumConfigs++;
  97. #else
  98.   NumConfigs += 3;
  99. #endif
  100.  
  101.   DBArg = dbargNew(
  102. #ifdef MESS
  103.         DBImage            = dbstringNew("Image", 1, 0, ""),
  104. #else
  105.         DBShow             = dbenumNew("Show", 1, 0, 1, dbshow_defs),
  106.         DBUseDefaults      = dbboolNew("UseDefaults", NumConfigs, 0, 1),
  107. #endif
  108.         DBFound            = dbboolNew("Found", NumConfigs, 0, 0),
  109.         DBScreenType       = dbenumNew("ScreenType", NumConfigs, 0, 0, dbscreentype_defs),
  110.         DBScreenMode       = dbuintNew("ScreenMode", NumConfigs, 0, INVALID_ID, 0xffffffff, 0),
  111.         DBDirectMode       = dbenumNew("DirectMode", NumConfigs, 0, 0, dbdirectmode_defs),
  112.         DBDirtyLines       = dbboolNew("DirtyLines", NumConfigs, 0, 1),
  113.         DBDepth            = dbintNew("Depth", NumConfigs, 0, 8, 32, 1),
  114.         DBAllow16Bit       = dbboolNew("Allow16Bit", NumConfigs, 0, 1),
  115.         DBFlipX            = dbboolNew("FlipX", NumConfigs, 0, 0),
  116.         DBFlipY            = dbboolNew("FlipY", NumConfigs, 0, 0),
  117.         DBAntialiasing     = dbboolNew("Antialiasing", NumConfigs, 0, 0),
  118.         DBTranslucency     = dbboolNew("Translucency", NumConfigs, 0, 0),
  119.         DBBeamWidth        = dbintNew("BeamWidth", NumConfigs, 0, 1, 16, 1),
  120.         DBVectorFlicker    = dbintNew("VectorFlicker", NumConfigs, 0, 0, 100, 0),
  121.         DBAutoFrameSkip    = dbboolNew("AutoFrameSkip", NumConfigs, 0, 0),
  122.         DBFrameSkip        = dbintNew("FrameSkip", NumConfigs, 0, 0, 3, 0),
  123.         DBWidth            = dbintNew("Width", NumConfigs, 0, 0, 4096, 0),
  124.         DBHeight           = dbintNew("Height", NumConfigs, 0, 0, 4096, 0),
  125.         DBBuffering        = dbenumNew("Buffering", NumConfigs, 0, 0, dbbuffering_defs),
  126.         DBRotation         = dbenumNew("Rotation", NumConfigs, 0, 0, dbrotation_defs),
  127.         DBSound            = dbenumNew("Sound", NumConfigs, 0, 1, dbsound_defs),
  128.         DBAudioChannel0    = dbintNew("AudioChannel0", NumConfigs, 0, 0, 15, 0),
  129.         DBAudioChannel1    = dbintNew("AudioChannel1", NumConfigs, 0, 1, 15, 0),
  130.         DBAudioChannel2    = dbintNew("AudioChannel2", NumConfigs, 0, 2, 15, 0),
  131.         DBAudioChannel3    = dbintNew("AudioChannel3", NumConfigs, 0, 3, 15, 0),
  132.         DBMinFreeChip      = dbintNew("MinFreeChip", NumConfigs, 0, 64, 2048, 0),
  133.         DBJoy1Type         = dbenumNew("Joy1Type", NumConfigs, 0, 1, dbjoy1type_defs),
  134.         DBJoy1ButtonBTime  = dbintNew("Joy1ButtonBTime", NumConfigs, 0, 0, 9, 0),
  135.         DBJoy1AutoFireRate = dbintNew("Joy1AutoFireRate", NumConfigs, 0, 0, 5, 0),
  136.         DBJoy2Type         = dbenumNew("Joy2Type", NumConfigs, 0, 0, dbjoy2type_defs),
  137.         DBJoy2ButtonBTime  = dbintNew("Joy2ButtonBTime", NumConfigs, 0, 0, 9, 0),
  138.         DBJoy2AutoFireRate = dbintNew("Joy2AutoFireRate", NumConfigs, 0, 0, 5, 0),
  139.         DBRomPath          = dbstringNew("RomPath", NumConfigs, 0, ""),
  140.         DBSamplePath       = dbstringNew("SamplePath", NumConfigs, 0, ""),
  141. #ifdef POWERUP        
  142.         DBAsyncPPC         = dbboolNew("AsyncPPC", NumConfigs, 0, 1),
  143. #endif
  144.       DBEND);
  145.  
  146.   NumConfigs--;
  147.  
  148.   if(argc > 1)
  149.   {
  150.     if(argv[1][0] != '-')
  151.     {
  152.       for(i = 0; Drivers[i]; i++)
  153.       {
  154.         if(!stricmp(Drivers[i]->name, argv[1]))
  155.         {
  156.           Config[CFG_DRIVER] = i;
  157.           break;
  158.         }
  159.       }
  160.     }
  161.   
  162.     if(Config[CFG_DRIVER] < 0)
  163.     {
  164.       if(argv[1][0] == '-')
  165.       {
  166.         if(argv[1][1] == '-')
  167.           i = 2;
  168.         else
  169.           i = 1;
  170.       }
  171.       else
  172.         i = 0;
  173.       
  174.       if(!stricmp(&argv[1][i], "list"))
  175.       {
  176.         printf("\n"APPNAME" includes these drivers:\n\n");
  177.         for(i = 0;  Drivers[i]; i++)
  178.         {
  179.           if(strlen(Drivers[i]->name) < 8)
  180.             printf("%s\t\t%s\n", Drivers[i]->name, Drivers[i]->description);
  181.           else
  182.             printf("%s\t%s\n", Drivers[i]->name, Drivers[i]->description);
  183.         }
  184.         printf("\nTotal drivers included: %4d\n", i);
  185.         return(TRUE);
  186.       }
  187.  
  188.       if((argv[1][0] == '?') || !stricmp(&argv[1][i], "help"))
  189.       {
  190.         printf("Usage: %s <driver> [options]\nOptions:\n", argv[0]);
  191.         dbargPrintHelp(DBArg);
  192.         return(TRUE);
  193.       }
  194.  
  195.       if(DBArg && (argc > 2) && (Config[CFG_DRIVER] < 0))
  196.         dbargParse(DBArg, argc-2, &argv[2], NumConfigs);
  197.  
  198.       if(!stricmp(&argv[1][i], "makedirs"))
  199.       {
  200.         MakeDirs();
  201.         return(TRUE);
  202.       }
  203.     }
  204.   }
  205.   
  206.   return(FALSE);
  207. }
  208.  
  209. void FreeConfig(void)
  210. {
  211.   if(DBArg)
  212.   {
  213.     if(SectionNames)
  214.     {
  215.       if(DBFile)
  216.       {
  217.         dbfileSave(DBFile);
  218.         Dispose(DBFile);
  219.       }
  220.     
  221.       free(SectionNames);
  222.     }
  223.  
  224.     Dispose(DBArg);
  225.   }
  226. }
  227.  
  228. void LoadConfig(int argc, char **argv)
  229. {
  230.   uint i;
  231.  
  232.   if(DBArg) 
  233.   {
  234.     SectionNames = malloc((NumConfigs + 1) * sizeof(char *));
  235.  
  236.     if(SectionNames)
  237.     {
  238. #ifdef MESS   
  239.       for(i = 0; i < NumConfigs; i++)
  240.         SectionNames[i] = (char *) Drivers[i]->description;
  241.     
  242.       SectionNames[i] = NULL;
  243.  
  244.       DBFile  = dbfileNew("mess.cfg",
  245. #else
  246.       SectionNames[0] = "Bitmap game defaults";
  247.       SectionNames[1] = "Vector game defaults";
  248.     
  249.       for(i = 2; i < NumConfigs; i++)
  250.         SectionNames[i] = (char *) Drivers[i-2]->description;
  251.     
  252.       SectionNames[i] = NULL;
  253.     
  254.       DBFile  = dbfileNew("mame.cfg",
  255.             dbsectionNew("MAME",
  256.               DBShow,
  257.             DBEND),
  258. #endif
  259.             dbsectionsNew(SectionNames,
  260. #ifndef MESS
  261.               DBUseDefaults,
  262. #endif
  263.               DBFound,
  264.               DBScreenType,
  265.               DBScreenMode,
  266.               DBDirectMode,
  267.               DBDirtyLines,
  268.               DBDepth,
  269.               DBAllow16Bit,
  270.               DBFlipX,
  271.               DBFlipY,
  272.               DBAntialiasing,
  273.               DBTranslucency,
  274.               DBBeamWidth,
  275.               DBVectorFlicker,
  276.               DBAutoFrameSkip,
  277.               DBFrameSkip,
  278.               DBWidth,
  279.               DBHeight,
  280.               DBBuffering,
  281.               DBRotation,
  282.               DBSound,
  283.               DBAudioChannel0,
  284.               DBAudioChannel1,
  285.               DBAudioChannel2,
  286.               DBAudioChannel3,
  287.               DBMinFreeChip,
  288.               DBJoy1Type,
  289.               DBJoy1ButtonBTime,
  290.               DBJoy1AutoFireRate,
  291.               DBJoy2Type,
  292.               DBJoy2ButtonBTime,
  293.               DBJoy2AutoFireRate,
  294.               DBRomPath,
  295.               DBSamplePath,
  296. #ifdef POWERUP              
  297.               DBAsyncPPC,
  298. #endif
  299.             DBEND),
  300.           DBEND);
  301.  
  302.       if((argc > 2) && (Config[CFG_DRIVER] >= 0))
  303.       {
  304. #ifdef MESS
  305.         dbargParse(DBArg, argc-2, &argv[2], Config[CFG_DRIVER]);
  306. #else
  307.         dbargParse(DBArg, argc-2, &argv[2], Config[CFG_DRIVER]+2);
  308. #endif
  309.       }
  310.     }
  311.   }
  312. }
  313.  
  314. void SetConfig(int index, LONG *cfg)
  315. {
  316.   if(DBArg)
  317.   {
  318. #ifdef MESS
  319.     dbstringSet( DBImage,            0,      (char *) cfg[CFG_IMAGE]);
  320. #else
  321.     dbenumSet(   DBShow,             0,      cfg[CFG_SHOW]);
  322.     dbboolSet(   DBUseDefaults,      index,  cfg[CFG_USEDEFAULTS]);
  323. #endif
  324.     dbenumSet(   DBScreenType,       index,  cfg[CFG_SCREENTYPE]);
  325.     dbuintSet(   DBScreenMode,       index,  cfg[CFG_SCREENMODE]);
  326.     dbenumSet(   DBDirectMode,       index,  cfg[CFG_DIRECTMODE]);
  327.     dbboolSet(   DBDirtyLines,       index,  cfg[CFG_DIRTYLINES]);
  328.     dbintSet(    DBDepth,            index,  cfg[CFG_DEPTH]);
  329.     dbboolSet(   DBAllow16Bit,       index,  cfg[CFG_ALLOW16BIT]);
  330.     dbboolSet(   DBFlipX,            index,  cfg[CFG_FLIPX]);
  331.     dbboolSet(   DBFlipY,            index,  cfg[CFG_FLIPY]);
  332.     dbboolSet(   DBAntialiasing,     index,  cfg[CFG_ANTIALIASING]);
  333.     dbboolSet(   DBTranslucency,     index,  cfg[CFG_TRANSLUCENCY]);
  334.     dbintSet(    DBBeamWidth,        index,  cfg[CFG_BEAMWIDTH]);
  335.     dbintSet(    DBVectorFlicker,    index,  cfg[CFG_VECTORFLICKER]);
  336.     dbboolSet(   DBAutoFrameSkip,    index,  cfg[CFG_AUTOFRAMESKIP]);
  337.     dbintSet(    DBFrameSkip,        index,  cfg[CFG_FRAMESKIP]);
  338.     dbintSet(    DBWidth,            index,  cfg[CFG_WIDTH]);
  339.     dbintSet(    DBHeight,           index,  cfg[CFG_HEIGHT]);
  340.     dbenumSet(   DBBuffering,        index,  cfg[CFG_BUFFERING]);
  341.     dbenumSet(   DBRotation,         index,  cfg[CFG_ROTATION]);
  342.     dbenumSet(   DBSound,            index,  cfg[CFG_SOUND]);
  343.     dbintSet(    DBAudioChannel0,    index,  cfg[CFG_AUDIOCHANNEL0]);
  344.     dbintSet(    DBAudioChannel1,    index,  cfg[CFG_AUDIOCHANNEL1]);
  345.     dbintSet(    DBAudioChannel2,    index,  cfg[CFG_AUDIOCHANNEL2]);
  346.     dbintSet(    DBAudioChannel3,    index,  cfg[CFG_AUDIOCHANNEL3]);
  347.     dbintSet(    DBMinFreeChip,      index,  cfg[CFG_MINFREECHIP]);
  348.     dbenumSet(   DBJoy1Type,         index,  cfg[CFG_JOY1TYPE]);
  349.     dbintSet(    DBJoy1ButtonBTime,  index,  cfg[CFG_JOY1BUTTONBTIME]);
  350.     dbintSet(    DBJoy1AutoFireRate, index,  cfg[CFG_JOY1AUTOFIRERATE]);
  351.     dbenumSet(   DBJoy2Type,         index,  cfg[CFG_JOY2TYPE]);
  352.     dbintSet(    DBJoy2ButtonBTime,  index,  cfg[CFG_JOY2BUTTONBTIME]);
  353.     dbintSet(    DBJoy2AutoFireRate, index,  cfg[CFG_JOY2AUTOFIRERATE]);
  354.     dbstringSet( DBRomPath,          index,  (char *) cfg[CFG_ROMPATH]);
  355.     dbstringSet( DBSamplePath,       index,  (char *) cfg[CFG_SAMPLEPATH]);
  356. #ifdef POWERUP
  357.     dbboolSet(   DBAsyncPPC,         index,  cfg[CFG_ASYNCPPC]);
  358. #endif
  359.   }
  360. }
  361.  
  362. void GetConfig(int index, LONG *cfg)
  363. {
  364.   if(DBArg)
  365.   {
  366. #ifdef MESS
  367.     cfg[CFG_IMAGE]            = (LONG) dbstringGet( DBImage,      0);
  368. #else
  369.     cfg[CFG_SHOW]             = dbenumGet( DBShow,       0);
  370.     cfg[CFG_USEDEFAULTS]      = dbboolGet( DBUseDefaults,      index);
  371. #endif
  372.     cfg[CFG_SCREENTYPE]       = dbenumGet( DBScreenType,       index);
  373.     cfg[CFG_SCREENMODE]       = dbuintGet( DBScreenMode,       index);
  374.     cfg[CFG_DIRECTMODE]       = dbenumGet( DBDirectMode,       index);
  375.     cfg[CFG_DIRTYLINES]       = dbboolGet( DBDirtyLines,       index);
  376.     cfg[CFG_DEPTH]            = dbintGet(  DBDepth,            index);
  377.     cfg[CFG_ALLOW16BIT]       = dbboolGet( DBAllow16Bit,       index);
  378.     cfg[CFG_FLIPX]            = dbboolGet( DBFlipX,            index);
  379.     cfg[CFG_FLIPY]            = dbboolGet( DBFlipY,            index);
  380.     cfg[CFG_ANTIALIASING]     = dbboolGet( DBAntialiasing,     index);
  381.     cfg[CFG_TRANSLUCENCY]     = dbboolGet( DBTranslucency,     index);
  382.     cfg[CFG_BEAMWIDTH]        = dbintGet(  DBBeamWidth,        index);
  383.     cfg[CFG_VECTORFLICKER]    = dbintGet(  DBVectorFlicker,    index);
  384.     cfg[CFG_AUTOFRAMESKIP]    = dbboolGet( DBAutoFrameSkip,    index);
  385.     cfg[CFG_FRAMESKIP]        = dbintGet(  DBFrameSkip,        index);
  386.     cfg[CFG_WIDTH]            = dbintGet(  DBWidth,            index);
  387.     cfg[CFG_HEIGHT]           = dbintGet(  DBHeight,           index);
  388.     cfg[CFG_BUFFERING]        = dbenumGet( DBBuffering,        index);
  389.     cfg[CFG_ROTATION]         = dbenumGet( DBRotation,         index);
  390.     cfg[CFG_SOUND]            = dbenumGet( DBSound,            index);
  391.     cfg[CFG_AUDIOCHANNEL0]    = dbintGet(  DBAudioChannel0,    index);
  392.     cfg[CFG_AUDIOCHANNEL1]    = dbintGet(  DBAudioChannel1,    index);
  393.     cfg[CFG_AUDIOCHANNEL2]    = dbintGet(  DBAudioChannel2,    index);
  394.     cfg[CFG_AUDIOCHANNEL3]    = dbintGet(  DBAudioChannel3,    index);
  395.     cfg[CFG_MINFREECHIP]      = dbintGet(  DBMinFreeChip,      index);
  396.     cfg[CFG_JOY1TYPE]         = dbenumGet( DBJoy1Type,         index);
  397.     cfg[CFG_JOY1BUTTONBTIME]  = dbintGet(  DBJoy1ButtonBTime,  index);
  398.     cfg[CFG_JOY1AUTOFIRERATE] = dbintGet(  DBJoy1AutoFireRate, index);
  399.     cfg[CFG_JOY2TYPE]         = dbenumGet( DBJoy2Type,         index);
  400.     cfg[CFG_JOY2BUTTONBTIME]  = dbintGet(  DBJoy2ButtonBTime,  index);
  401.     cfg[CFG_JOY2AUTOFIRERATE] = dbintGet(  DBJoy2AutoFireRate, index);
  402. #ifdef POWERUP
  403.     cfg[CFG_ASYNCPPC]         = dbboolGet(DBAsyncPPC,index);
  404. #endif
  405.     cfg[CFG_ROMPATH]          = (LONG) dbstringGet( DBRomPath,      index);
  406.     cfg[CFG_SAMPLEPATH]       = (LONG) dbstringGet( DBSamplePath,   index);
  407.   }
  408.   else
  409.   {
  410. #ifdef MESS
  411.     cfg[CFG_IMAGE]            = (LONG) "";
  412. #else
  413.     cfg[CFG_SHOW]             = 1;
  414.     cfg[CFG_USEDEFAULTS]      = FALSE;
  415. #endif
  416.     cfg[CFG_SCREENTYPE]       = CFGST_BEST;
  417.     cfg[CFG_SCREENMODE]       = INVALID_ID;
  418.     cfg[CFG_DIRECTMODE]       = CFGDM_OFF;
  419.     cfg[CFG_DIRTYLINES]       = TRUE;
  420.     cfg[CFG_DEPTH]            = 8;
  421.     cfg[CFG_ALLOW16BIT]       = TRUE;
  422.     cfg[CFG_FLIPX]            = FALSE;
  423.     cfg[CFG_FLIPY]            = FALSE;
  424.     cfg[CFG_ANTIALIASING]     = FALSE;
  425.     cfg[CFG_TRANSLUCENCY]     = FALSE;
  426.     cfg[CFG_BEAMWIDTH]        = 1;
  427.     cfg[CFG_VECTORFLICKER]    = 0;
  428.     cfg[CFG_AUTOFRAMESKIP]    = FALSE;
  429.     cfg[CFG_FRAMESKIP]        = 0;
  430.     cfg[CFG_WIDTH]            = 0;
  431.     cfg[CFG_HEIGHT]           = 0;
  432.     cfg[CFG_BUFFERING]        = CFGB_SINGLE;
  433.     cfg[CFG_ROTATION]         = CFGR_NO;
  434.     cfg[CFG_SOUND]            = CFGS_PAULA;
  435.     cfg[CFG_AUDIOCHANNEL0]    = 0;
  436.     cfg[CFG_AUDIOCHANNEL1]    = 1;
  437.     cfg[CFG_AUDIOCHANNEL2]    = 2;
  438.     cfg[CFG_AUDIOCHANNEL3]    = 3;
  439.     cfg[CFG_MINFREECHIP]      = 64;
  440.     cfg[CFG_JOY1TYPE]         = CFGJ1_JOYSTICK2;
  441.     cfg[CFG_JOY1BUTTONBTIME]  = 0;
  442.     cfg[CFG_JOY1AUTOFIRERATE] = 0;
  443.     cfg[CFG_JOY2TYPE]         = CFGJ2_NO;
  444.     cfg[CFG_JOY2BUTTONBTIME]  = 0;
  445.     cfg[CFG_JOY2AUTOFIRERATE] = 0;
  446.     cfg[CFG_ROMPATH]          = NULL;
  447.     cfg[CFG_SAMPLEPATH]       = NULL;
  448. #ifdef POWERUP
  449.     cfg[CFG_ASYNCPPC]         = TRUE;
  450. #endif
  451.   }
  452. }
  453.  
  454. #ifndef MESS
  455. int GetUseDefaults(int index)
  456. {
  457.   if(DBArg)
  458.     return(dbboolGet(DBUseDefaults, index));
  459.   else
  460.     return(TRUE);
  461. }
  462. #endif
  463.  
  464. void MakeDirs(void)
  465. {
  466.   const char *rom_path;
  467.   BPTR  dir, old_dir, new_dir;
  468.   LONG  i;
  469.  
  470.   dir     = NULL;
  471.   old_dir = NULL;
  472.  
  473.   rom_path = GetRomPath(NumConfigs, 0);
  474.  
  475.   if(rom_path && strlen(rom_path))
  476.   {
  477.     dir = Lock((STRPTR) rom_path, ACCESS_READ);
  478.     
  479.     if(!dir)
  480.       dir = CreateDir((STRPTR) rom_path);
  481.  
  482.     if(dir)
  483.       old_dir = CurrentDir(dir);
  484.   }
  485.  
  486.   for(i = 0;  Drivers[i]; i++)
  487.   {
  488.     new_dir = CreateDir((STRPTR)Drivers[i]->name);
  489.     
  490.     if(new_dir)
  491.       UnLock(new_dir);
  492.   }
  493.  
  494.   if(dir)
  495.   {
  496.     CurrentDir(old_dir);
  497.     UnLock(dir);
  498.   }
  499. }
  500.  
  501. const char *GetRomPath(int index, int path_num)
  502. {
  503.   const char *rom_path;
  504.  
  505.   switch(path_num)
  506.   {
  507.     case 0:
  508.       rom_path = dbstringGet(DBRomPath, index);
  509.       
  510.       break;
  511.  
  512. #ifndef MESS
  513.     case 1:
  514.       if(Drivers[index]->drv->video_attributes & VIDEO_TYPE_VECTOR)
  515.         rom_path = dbstringGet(DBRomPath, 1);
  516.       else
  517.         rom_path = dbstringGet(DBRomPath, 0);
  518.       
  519.       break;
  520.  
  521.     case 2:
  522.       if(Drivers[index]->drv->video_attributes & VIDEO_TYPE_VECTOR)
  523.         rom_path = dbstringGet(DBRomPath, 0);
  524.       else
  525.         rom_path = dbstringGet(DBRomPath, 1);
  526.  
  527.       break;
  528. #endif
  529.  
  530.     default:
  531.       rom_path = NULL;
  532.       
  533.       break;
  534.   }
  535.   
  536.   return(rom_path);
  537. }
  538.  
  539. const char *GetSamplePath(int index, int path_num)
  540. {
  541.   const char *sample_path;
  542.  
  543.   switch(path_num)
  544.   {
  545.     case 0:
  546.       sample_path = dbstringGet(DBSamplePath, index);
  547.       
  548.       break;
  549.  
  550. #ifndef MESS
  551.     case 1:
  552.       if(Drivers[index]->drv->video_attributes & VIDEO_TYPE_VECTOR)
  553.         sample_path = dbstringGet(DBSamplePath, 1);
  554.       else
  555.         sample_path = dbstringGet(DBSamplePath, 0);
  556.       
  557.       break;
  558.  
  559.     case 2:
  560.       if(Drivers[index]->drv->video_attributes & VIDEO_TYPE_VECTOR)
  561.         sample_path = dbstringGet(DBSamplePath, 0);
  562.       else
  563.         sample_path = dbstringGet(DBSamplePath, 1);
  564.  
  565.       break;
  566. #endif
  567.  
  568.     default:
  569.       sample_path = NULL;
  570.       
  571.       break;
  572.   }
  573.   
  574.   return(sample_path);
  575. }
  576.  
  577. BOOL GetFound(int driver)
  578. {
  579.   if(dbboolGet(DBFound, driver))
  580.     return(TRUE);
  581.  
  582.   return(FALSE);
  583. }
  584.  
  585. void SetFound(int driver, BOOL found)
  586. {
  587.   dbboolSet(DBFound, driver, found);
  588. }
  589.